package cn.yunyichina.provider.sys.service.impl;

import cn.yunyichina.provider.iface.entity.common.ResponseObject;
import cn.yunyichina.provider.sys.dao.CardPeopleDao;
import cn.yunyichina.provider.sys.dao.OrderCountDao;
import cn.yunyichina.provider.sys.entity.vo.CardPeopleVo;
import cn.yunyichina.provider.sys.entity.vo.OrderCountVo;
import cn.yunyichina.utils.json.Jackson;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/3/12.
 */
@Service
public class ReportServiceImpl  {
    private static final Logger logger = LoggerFactory.getLogger(ReportServiceImpl.class);

    @Autowired
    private CardPeopleDao peopleDao;

    @Autowired
    private OrderCountDao orderCountDao;

    /**
     * 绑卡人数统计
     * yyt.sys.report.cardpeople
     * @param json
     * @return
     */
    public ResponseObject cardpeopleReport(String json,String sessionId) {
        logger.info("ReportServiceImpl.cardpeopleReport.json -> {}", json);

        CardPeopleVo requestVO = Jackson.fromJson(json, CardPeopleVo.class);


        List<String> hospitalIds = new ArrayList();
        hospitalIds.add("bjdxszyy");
        hospitalIds.add("szdsrmyy");

        requestVO.setOrgCodeList(hospitalIds);
        List<CardPeopleVo> list  = peopleDao.groupByDate(requestVO);

        return new ResponseObject().buildResultObject(list);
    }

    /**
     * 绑卡数统计
     * yyt.sys.report.cardnum
     * @param json
     * @return
     */
    public ResponseObject cardnumReport(String json,String sessionId) {
        logger.info("ReportServiceImpl.cardnumReport.json -> {}", json);

        CardPeopleVo requestVO = Jackson.fromJson(json, CardPeopleVo.class);


        List<String> hospitalIds = new ArrayList();
        hospitalIds.add("bjdxszyy");
        hospitalIds.add("szdsrmyy");

        requestVO.setOrgCodeList(hospitalIds);
        List<CardPeopleVo> list  = peopleDao.groupCardNumByDate(requestVO);

        return new ResponseObject().buildResultObject(list);
    }

    /**
     * yyt.sys.report.ordercount
     *交易笔数统计(按订单类型)
     * @param json
     * @return
     */
    public ResponseObject OrderCountReport(String json,String sessionId) {
        logger.info("ReportServiceImpl.cardnumReport.json -> {}", json);

        OrderCountVo requestVO = Jackson.fromJson(json, OrderCountVo.class);


        List<String> hospitalIds = new ArrayList();
        hospitalIds.add("bjdxszyy");
        hospitalIds.add("szdsrmyy");

        requestVO.setOrgCodeList(hospitalIds);
        List<OrderCountVo> list  = orderCountDao.groupByDate(requestVO);

        return new ResponseObject().buildResultObject(list);
    }
}
